#!/bin/sh

retry=0
max_retry=4

while [ 1 ]
do
  DEBIAN_FRONTEND=noninteractive apt-get update -q
  DEBIAN_FRONTEND=noninteractive apt-get install -y -q "$@"
  return_value=$?
  [ "$return_value" = 0 ] && break
  [ "$retry" = "$max_retry" ] && exit $return_value

  echo "================================================="
  echo "($retry) Install failed... Retrying after some seconds"
  echo "================================================="
  sleep 60
  retry=$((retry+1))
done
